package com.qingcheng.service.impl;

import com.qingcheng.service.goods.BrandService;
import com.qingcheng.service.goods.CategoryService;
import com.qingcheng.service.goods.SkuService;
import com.qingcheng.service.goods.SpecService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;

@Controller
public class Init implements InitializingBean {

    @Autowired
    private CategoryService categoryService;
    @Autowired
    private SkuService skuService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private SpecService specService;
    @Autowired
    private BrandService brandService;
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("缓存预热");
       /* categoryService.saveCategoryTreeToRedis();//保存所有菜单分页到缓存
        skuService.saveAllPriceToRedis();//保存所有价格到缓存
        skuService.importToEs();
        //品牌列表缓存预热
        if (!redisTemplate.hasKey(CacheKey.BARND_LIST)){
            brandService.saveToRedis();
        }
        //规格列表缓存预热
        if (!redisTemplate.hasKey(CacheKey.SPEC_LIST)){
            specService.saveToRedis();
        }*/
    }
}
